<%@ page language="java" contentType="text/html; charset=utf-8" pageEncoding="utf-8"%>

<!-- 开启定时器，时间紧急，暂时用轮询方式作出判断 -->
<script type="text/javascript">
var prePath = window.document.location.href;
var pathName = window.document.location.pathname;
var pos = prePath.indexOf(pathName);
var localhostPath = prePath.substring(0, pos);
var projectName = pathName.substring(0, pathName.substr(1).indexOf('/') + 1);
rootPath = localhostPath + projectName;

var totalNum = 0;

function showNote(){
	    //判断浏览器是否支持notification
	    if(window.webkitNotifications){
	        //判断当前页面是否被允许发出通知
	        if(webkitNotifications.checkPermission()==0){
	            var icon_url = '<%=request.getContextPath()%>/images/Notification.png';
	            var title = '消息提醒：';
	            var body = '您有新的订单!';
	           var WebkitNotification = webkitNotifications.createNotification(icon_url, title, body);
	           WebkitNotification.onclick=function(g){
					//console.log("click事件被触发:",g);
					//window.location.href= rootPath + "/order/query";
					window.open(rootPath + "/order/query", "_blank");
					f.close();
			   };
			   WebkitNotification.show();
	        }else{
	                webkitNotifications.requestPermission();
	        }
	    }
	};
//判断当前用户是否有新订单生成
function polling(){
	$.ajax({
		url:"${pageContext.request.contextPath}/order/pull",
		type:"POST",
		data:{totalNum : totalNum},
		dataType:"json",
		success:function(data){
			//判断出有变化 ，则作出提示
			if(data.flag){
				showNote();
			}
			//更新前台计数
			totalNum = data.totalNum;
		},
		error:function(){
			
		}
	});
}
var id = window.setInterval('polling()',10000);//5秒
	
</script>


<!--  -->

<div class="header">
	<div class="header-top">
		<div style="float: left">
			<img src="<c:url value="/images/logo.png"/>"
				style="height: 35px; margin-top: 5px;" />
		</div>
		<div style="float: right;" class="exit">
			<div style="float: right;">
				<img src="<c:url value="/images/admin.png"/>" style="margin-top:10px;"/>	
			</div>
			<div style="float:right;margin-right:10px;">
				<p style="text-align: center;">欢迎您：${customer.name}&nbsp;&nbsp;&nbsp;</p>
				<c:if test="${customer.type eq 1}">
					<a id="alter" href="<c:url value="/updatePwd"/>" style="margin-right:5px;display:none;">修改密码</a> 
				</c:if>
				<a id="exit" href="<c:url value="/logout"/>">退出</a>
			</div>
		</div>
	</div>
	<div class="header-bottom">
		<div class="nav">
			<ul>
				<li id="_order"><a href="<c:url value="/order/query"/>">订单管理</a></li>
				<c:if test="${customer.type eq 1}">
				<li id="_product"><a href="<c:url value="/product/query"/>">商品管理</a></li>
				<li id="_activity"><a href="<c:url value="/activity/query"/>">活动管理</a></li>
				<li id="_user"><a href="<c:url value="/userManage/query"/>">会员管理</a></li>
				<li id="_category"><a href="<c:url value="/categorym/query"/>">店铺管理</a></li>
				<li id="_recommend"><a href="<c:url value="/recommend/query"/>">推荐管理</a></li>
				<li id="_rproduct"><a href="<c:url value="/rproduct/query"/>">红商品管理</a></li>
				 <li id="_config"><a href="<c:url value="/config/query/wcpay"/>">配置管理</a></li>
				
				<!--	 <li id="_customer"><a href="<c:url value="/customer/queryCst"/>">商铺管理</a></li>-->
				</c:if>
				<li id="_updatePwd" style="display:none;"><a href="<c:url value="/updatePwd"/>">管理员管理</a></li>
			</ul>
		</div>
	</div>
</div>
